package meforbio.wip.pint;

public class Frappe extends VirtualFrappe {


	/**
	 * TODO Exception sur les frappes incorrectes
	 */
	
	private Sorte sorteSrc;
	private int processSrc;
	private Sorte sorteDest;
	private int processDestHitted;
	private int processDestJumped;
	private String label;
	
	public Sorte getSorteSrc() {
		return sorteSrc;
	}

	public void setSorteSrc(Sorte sorteSrc) {
		this.sorteSrc = sorteSrc;
	}

	public int getProcessSrc() {
		return processSrc;
	}

	public void setProcessSrc(int processSrc) {
		this.processSrc = processSrc;
	}

	public Sorte getSorteDest() {
		return sorteDest;
	}

	public void setSorteDest(Sorte sorteDest) {
		this.sorteDest = sorteDest;
	}

	public int getProcessDestHitted() {
		return processDestHitted;
	}

	public void setProcessDestHitted(int processDestHitted) {
		this.processDestHitted = processDestHitted;
	}

	public int getProcessDestJumped() {
		return processDestJumped;
	}

	public void setProcessDestJumped(int processDestJumped) {
		this.processDestJumped = processDestJumped;
	}

	public Frappe(Sorte src, int processSrc, Sorte dest, int processHitted, int processJumped)
	{
		this.sorteSrc = src;
		this.processSrc = processSrc;
		this.sorteDest = dest;
		this.processDestHitted = processHitted;
		this.processDestJumped = processJumped;
		this.label = "";
	}
	
	public Frappe(Sorte src, int processSrc, Sorte dest, int processHitted, int processJumped, String label)
	{
		this.sorteSrc = src;
		this.processSrc = processSrc;
		this.sorteDest = dest;
		this.processDestHitted = processHitted;
		this.processDestJumped = processJumped;
		this.label = label;
	}
	
	public String toString()
	{
		return "(*"+this.label+"*)\n"+ProcessHitting.addUnderscore(sorteSrc.getId()) +" " + processSrc +" -> " +  ProcessHitting.addUnderscore(sorteDest.getId()) +" " +processDestHitted +" " + processDestJumped;
	}
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + processDestHitted;
		result = prime * result + processDestJumped;
		result = prime * result + processSrc;
		result = prime * result
				+ ((sorteDest == null) ? 0 : sorteDest.hashCode());
		result = prime * result
				+ ((sorteSrc == null) ? 0 : sorteSrc.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Frappe other = (Frappe) obj;
		if (processDestHitted != other.processDestHitted)
			return false;
		if (processDestJumped != other.processDestJumped)
			return false;
		if (processSrc != other.processSrc)
			return false;
		if (sorteDest == null) {
			if (other.sorteDest != null)
				return false;
		} else if (!sorteDest.equals(other.sorteDest))
			return false;
		if (sorteSrc == null) {
			if (other.sorteSrc != null)
				return false;
		} else if (!sorteSrc.equals(other.sorteSrc))
			return false;
		return true;
	}
}
